//构造函数
function sort(arr){
    this.arr=arr
}
let arr=new sort([1,5,13,17,22,15,8,6])
sort.prototype.sorting=function(){
   let arr1=this.arr
   for(let i=0;i<arr1.length;i++){
       for(let j=0;j<arr1.length-i-1;j++){
           if(arr1[j]>arr1[j+1]){
               let t=arr1[j]
               arr1[j]=arr1[j+1]
               arr1[j+1]=t
           }
       }
   }
   return arr1
}
console.log("从小到大排序："+arr.sorting());
sort.prototype.sorting1=function(){
    let arr2=this.arr
    for(let i=0;i<arr2.length;i++){
        for(let j=0;j<arr2.length-i-1;j++){
            if(arr2[j]<arr2[j+1]){
                let t=arr2[j]
                arr2[j]=arr2[j+1]
                arr2[j+1]=t
            }
        }
    }
    return arr2
 }
 console.log("从大到小排序："+arr.sorting1());